package com.hm.mapper;

import com.hm.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    @Select("select * from user where username = #{username}")
    User findUserByUsername(String username);

    @Select("insert into user(username, password, create_time, update_time)" +
            " values(#{username}, #{password}, now(), now())")
    void insertUser(String username, String password);

    @Select("update user set email = #{email},nickname = #{nickname}, update_time = now() where id = #{id}")
    void update(User user);

    @Select("update user set user_pic = #{avatar}, update_time = now() where id = #{id}")
    void updateAvata(String avatar,Integer id);

    @Select("update user set password = #{newPwd}, update_time = now() where id = #{id}")
    void updatePwd(String newPwd, Integer id);
}
